package com.pen.changgou.common.core;

import com.pen.changgou.common.core.entity.Result;
import com.pen.changgou.common.core.entity.StatusCode;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @author YaoDao
 * @version 1.0
 * @Description
 * @date 2020/11/25 1:36
 */
//@ControllerAdvice
@Slf4j
public class BaseExceptionHandler {
    /***
     * 异常处理
     * @param e
     * @return
     */
    @ExceptionHandler(value = Exception.class)
    @ResponseBody
    public Result error(Exception e) {
        log.info("全局异常，具体信息：｛｝", e.getMessage());
        return new Result(false, StatusCode.ERROR, "网络异常，请稍后重试");
    }
}
